package com.example.yichuangyun.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;

import com.example.yichuangyun.service.MyPhoneService;

public class PhoneBroadcastReceiver extends BroadcastReceiver {

    private Intent mIntent;

    @Override
    public void onReceive(Context context, Intent intent) {
        if (null == mIntent) {
            mIntent = new Intent(context, MyPhoneService.class);
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            context.startForegroundService(mIntent);
        } else {
            context.startService(mIntent);
        }
    }
}
